package com.ruoyi.system.controller;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.data.TextRenderData;
import com.deepoove.poi.data.style.Style;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysQuestion;
import com.ruoyi.common.core.domain.entity.SysQuestionDomain;
import com.ruoyi.common.core.domain.entity.SysQuestionRecord;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysCompanyInfo;
import com.ruoyi.system.domain.SysCompanyMember;
import com.ruoyi.system.domain.SysNaire;
import com.ruoyi.system.domain.vo.SysDeptReqVo;
import com.ruoyi.system.domain.vo.SysDeptVo;
import com.ruoyi.system.domain.vo.SysQuestionReqVo;
import com.ruoyi.system.dto.CompanyDiagnoseScore;
import com.ruoyi.system.dto.OptionConfig;
import com.ruoyi.system.dto.QuestionDomainScore;
import com.ruoyi.system.dto.SysDeptDto;
import com.ruoyi.system.enums.CompanyLevelEnum;
import com.ruoyi.system.mapper.SysCompanyMemberMapper;
import com.ruoyi.system.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import utils.ExcelResponse;
import utils.ScoreUtils;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 企业诊断列表Controller
 * 
 * @author ruoyi
 * @date 2023-06-09
 */
@Api(tags = "企业诊断列表")
@RestController
@RequestMapping("/system/company")
public class SysCompanyDiagnoseController extends BaseController
{
    @Autowired
    private ISysCompanyDiagnoseService sysCompanyDiagnoseService;

    @Autowired
    private ISysQuestionService sysQuestionService;

    @Autowired
    private ISysNaireService sysNaireService;

    @Autowired
    private ISysQuestionRecordService sysQuestionRecordService;

    @Autowired
    private ISysQuestionDomainService domainService;

    @Autowired
    private ISysCompanyInfoService sysCompanyInfoService;

    @Autowired
    private SysCompanyMemberMapper sysCompanyMemberMapper;

    /** 评测表导出模板路径 */
    public static final String DIGITAL_TEST_WORD_TEMPLATE_PATH = "templates/word/digital_test.docx";

    /** 诊断报告导出模板路径 */
    public static final String DIGITAL_REPORT_WORD_TEMPLATE_PATH = "templates/word/digital_report.docx";

    /**
     * 查询企业诊断列表
     */
    @ApiOperation(value = "查询企业诊断列表")
   // @PreAuthorize("@ss.hasPermi('system:company:list')")
    @GetMapping("/list")
    public TableDataInfo selectSysDeptReqList(SysDeptReqVo dept)
    {

        if(!getLoginUser().getUser().isAdmin()){
            dept.setUserId(getLoginUser().getUserId());
        }
        if(dept.getUserId()!=null){
            SysCompanyMember sysCompanyMember=new SysCompanyMember();
            sysCompanyMember.setUserId(dept.getUserId());

            List<SysCompanyMember> sysCompanyMembers=sysCompanyMemberMapper.selectSysCompanyMemberList(sysCompanyMember);

            if(CollUtil.isNotEmpty(sysCompanyMembers)){
                Set<Long> deptIds=sysCompanyMembers.stream().map(sysCompanyMember1 -> {
                    return  sysCompanyMember1.getDeptId();
                }).collect(Collectors.toSet());
                dept.setDeptIds(deptIds);
            }else{
                return getDataTable( new ArrayList<>());
            }
        }
        startPage();
        List<SysDeptVo> list= sysCompanyDiagnoseService.selectSysDeptReqList(dept);
        return getDataTable(list);
    }

    /**
     * 新建企业诊断
     * @param sysDeptDto
     */
    @ApiOperation(value = "新建企业诊断")
    @Log(title = "新建企业诊断", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SysDeptDto sysDeptDto)
    {
        int result=sysCompanyDiagnoseService.updateSysDeptDto(sysDeptDto);
        if(result==-1){
            return AjaxResult.error("该企业已存在企业诊断列表");
        }
        return toAjax(result);
    }


    /**
     * 企业测评表结束评分
     * @param deptId
     */
    @ApiOperation(value = "企业测评表结束评分")
    @Log(title = "企业测评表结束评分", businessType = BusinessType.UPDATE)
    @PutMapping("/test/end/{deptId}")
    public AjaxResult testEnd(@PathVariable("deptId") Long deptId)
    {
        int result=sysCompanyDiagnoseService.testEnd(deptId);
        if (result==-1)
        {
            return AjaxResult.error("该企业暂未完成测评表评分填写");
        }
        return toAjax(result);
    }

    /**
     * 删除诊断企业
     */
    @ApiOperation(value = "删除诊断企业")
    //  @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "删除诊断企业", businessType = BusinessType.DELETE)
    @DeleteMapping("/{deptId}")
    public AjaxResult remove(@PathVariable("deptId") Long deptId)
    {
        return toAjax(sysCompanyDiagnoseService.deleteSysDeptDto(deptId));
    }


    @ApiOperation(value = "导出企业诊断评测表")
    @GetMapping("/digital/test/word")
    public void exportDigitalTestWord(SysQuestionReqVo questionReqVo,HttpServletResponse response) throws IOException {

        Configure config = Configure.builder()
                // isStrict = false , 关闭严格模式, 严格模式下key不存在会报错
                // 关闭后key不存在会被忽略
                // .useSpringEL(true)
                // 表格绑定policy
                .build();

        ClassPathResource classPathResource = new ClassPathResource(DIGITAL_TEST_WORD_TEMPLATE_PATH);

        SysNaire naire = sysNaireService.selectSysNaireByNaireId(questionReqVo.getNaireId());

        Set<Long> quesetionIdList = Arrays.stream(naire.getQuestions().substring(1, naire.getQuestions().length() - 1).split(","))
                .map(s -> Long.parseLong(s.trim()))
                .collect(Collectors.toSet());

        List<SysQuestion> questions = sysQuestionService.selectSysQuestionByQuestionIds(quesetionIdList);

        SysQuestionRecord query=new SysQuestionRecord();
        query.setCompanyId(questionReqVo.getCompanyId());
        query.setNaireId(questionReqVo.getNaireId());
        query.setQuestionId(questionReqVo.getQuestionId());
        List<SysQuestionRecord>  questionRecords=sysQuestionRecordService.selectSysQuestionRecordList(query);

        // 字体Wingdings 2的符号
        TextRenderData selSymbol = new TextRenderData("R",new Style("Wingdings 2",10));//勾选框

        TextRenderData unselSymbol = new TextRenderData("\u00A3",new Style("Wingdings 2",10));//空框

        Map<String, Object> map=new HashMap<String, Object>();

        for (SysQuestion question : questions) {

            JSONObject jsonObject = JSONObject.parseObject(question.getDetail());
            JSONArray options = jsonObject.getJSONArray("options");


            SysQuestionRecord record=new SysQuestionRecord();

            if(CollUtil.isNotEmpty(questionRecords)){
                for (SysQuestionRecord questionRecord : questionRecords) {
                    if(questionRecord.getQuestionId().equals(question.getQuestionId())){
                        record=questionRecord;
                        break;
                    }
                }
            }


            if(CollUtil.isNotEmpty(options)){
                for (int i=0;i<options.size();i++) {
                    JSONObject option = options.getJSONObject(i);
                    String value=option.getString("value");

                    if(record!=null&&record.getAnswer()!=null){
                        int index = Integer.parseInt(record.getAnswer());
                        if(index==i){
                            map.put(question.getSort()+"_"+value,selSymbol);
                            continue;
                        }
                    }
                    map.put(question.getSort()+"_"+value,unselSymbol);
                }
            }


            if(question.getSort()>21&&record!=null){
                map.put("tag"+question.getSort(),record.getOther()!=null?record.getOther():"");
            }
        }

        XWPFTemplate template = XWPFTemplate.compile(classPathResource.getInputStream(),config).render(map);
        OutputStream os = response.getOutputStream();
        // 响应到客户端
        ExcelResponse.disposition(response, "测评表结果" + ".docx", "attachment", 0);
        template.write(os);
        os.flush();
        os.close();
        if (template != null) {
            template.close();
        }
    }


    /**
     * 查询企业测评表总分
     */
    @ApiOperation(value = "查询企业测评表总分")
    // @PreAuthorize("@ss.hasPermi('system:company:list')")
    @GetMapping("/diagnose/total/score")
    public AjaxResult selectCompanyDiagnoseScore(SysQuestionReqVo questionReqVo)
    {
        CompanyDiagnoseScore companyDiagnoseScore=new CompanyDiagnoseScore();

        SysQuestionDomain domain=new SysQuestionDomain();
        domain.setWeight(1);
        List<SysQuestionDomain> domains = domainService.selectQuestionDomainList(domain);





        SysNaire naire = sysNaireService.selectSysNaireByNaireId(questionReqVo.getNaireId());

        Set<Long> quesetionIdList = Arrays.stream(naire.getQuestions().substring(1, naire.getQuestions().length() - 1).split(","))
                .map(s -> Long.parseLong(s.trim()))
                .collect(Collectors.toSet());

        List<SysQuestion> questions = sysQuestionService.selectSysQuestionByQuestionIds(quesetionIdList);

        SysQuestionRecord query=new SysQuestionRecord();
        query.setCompanyId(questionReqVo.getCompanyId());
        query.setNaireId(questionReqVo.getNaireId());
        query.setQuestionId(questionReqVo.getQuestionId());
        List<SysQuestionRecord>  questionRecords=sysQuestionRecordService.selectSysQuestionRecordList(query);

        List<List<SysQuestionRecord>> resultList = ScoreUtils.groupDataByCondition(questionRecords,new Comparator<SysQuestionRecord>(){
            @Override
            public int compare(SysQuestionRecord o1, SysQuestionRecord o2) {
                return o1.getQuestionId().equals(o2.getQuestionId()) ? 0 : -1;
            }
        });

        if(CollUtil.isNotEmpty(questions)){
            for (SysQuestion question:questions){
                if(CollUtil.isNotEmpty(resultList)){
                    for (List<SysQuestionRecord> list : resultList) {
                        if(list.get(0).getQuestionId().equals(question.getQuestionId())){
                            question.setRecords(list);
                            break;
                        }
                    }
                }
            }
        }



        List<List<SysQuestion>> questionList= ScoreUtils.groupDataByCondition(questions,new Comparator<SysQuestion>(){
            @Override
            public int compare(SysQuestion o1, SysQuestion o2) {
                return o1.getDomain().equals(o2.getDomain()) ? 0 : -1;
            }
        });

        // 二级指标分数
        List<QuestionDomainScore> secondDomainScores=new ArrayList<>();
        for (SysQuestionDomain sysQuestionDomain:domains){

            if(sysQuestionDomain.getParentId().longValue()!=0){
                for (List<SysQuestion> sysQuestions:questionList){
                    if(sysQuestionDomain.getDomainId().equals(sysQuestions.get(0).getDomain())){
                        secondDomainScores.add(ScoreUtils.getSecondScore(sysQuestionDomain,sysQuestions));
                        break;
                    }
                }
            }
        }



        List<List<QuestionDomainScore>> questionDomainScoreList= ScoreUtils.groupDataByCondition(secondDomainScores,new Comparator<QuestionDomainScore>(){
            @Override
            public int compare(QuestionDomainScore o1, QuestionDomainScore o2) {
                return o1.getParentId().equals(o2.getParentId()) ? 0 : -1;
            }
        });
        // 一级指标分数
        List<QuestionDomainScore> firstDomainScores=new ArrayList<>();
        for (SysQuestionDomain sysQuestionDomain:domains){

            if(sysQuestionDomain.getParentId().longValue()==0){
                for (List<QuestionDomainScore> questionDomainScores1:questionDomainScoreList){
                    if(sysQuestionDomain.getDomainId().equals(questionDomainScores1.get(0).getParentId())){
                        firstDomainScores.add(ScoreUtils.getFirstScore(sysQuestionDomain,questionDomainScores1));
                        break;
                    }
                }
            }
        }

        BigDecimal totalScore=new BigDecimal("0.00");
        for (QuestionDomainScore questionDomainScore:firstDomainScores){

            totalScore=totalScore.add(new BigDecimal(questionDomainScore.getScore()));
        }

        companyDiagnoseScore.setTotalScore(totalScore.toString());

        if(CompanyLevelEnum.ONE.getScore()>=totalScore.doubleValue()){
            companyDiagnoseScore.setLevel(CompanyLevelEnum.ONE.getLevel());
        }else if(CompanyLevelEnum.TWO.getScore()>=totalScore.doubleValue()){
            companyDiagnoseScore.setLevel(CompanyLevelEnum.TWO.getLevel());
        }else if(CompanyLevelEnum.THREE.getScore()>=totalScore.doubleValue()){
            companyDiagnoseScore.setLevel(CompanyLevelEnum.THREE.getLevel());
        }else if(CompanyLevelEnum.FOUR.getScore()>=totalScore.doubleValue()){
            companyDiagnoseScore.setLevel(CompanyLevelEnum.FOUR.getLevel());
        }

        return AjaxResult.success(companyDiagnoseScore);
    }


    /**
     * 查询企业测评表一级指标分数
     */
    @ApiOperation(value = "查询企业测评表一级指标分数")
    // @PreAuthorize("@ss.hasPermi('system:company:list')")
    @GetMapping("/diagnose/first/score")
    public AjaxResult selectCompanyDiagnoseFirstScore(SysQuestionReqVo questionReqVo){
        SysQuestionDomain domain=new SysQuestionDomain();
        domain.setWeight(1);
        List<SysQuestionDomain> domains = domainService.selectQuestionDomainList(domain);

        SysNaire naire = sysNaireService.selectSysNaireByNaireId(questionReqVo.getNaireId());

        Set<Long> quesetionIdList = Arrays.stream(naire.getQuestions().substring(1, naire.getQuestions().length() - 1).split(","))
                .map(s -> Long.parseLong(s.trim()))
                .collect(Collectors.toSet());

        List<SysQuestion> questions = sysQuestionService.selectSysQuestionByQuestionIds(quesetionIdList);

        SysQuestionRecord query=new SysQuestionRecord();
        query.setCompanyId(questionReqVo.getCompanyId());
        query.setNaireId(questionReqVo.getNaireId());
        query.setQuestionId(questionReqVo.getQuestionId());
        List<SysQuestionRecord>  questionRecords=sysQuestionRecordService.selectSysQuestionRecordList(query);

        List<List<SysQuestionRecord>> resultList = ScoreUtils.groupDataByCondition(questionRecords,new Comparator<SysQuestionRecord>(){
            @Override
            public int compare(SysQuestionRecord o1, SysQuestionRecord o2) {
                return o1.getQuestionId().equals(o2.getQuestionId()) ? 0 : -1;
            }
        });

        if(CollUtil.isNotEmpty(questions)){
            for (SysQuestion question:questions){
                if(CollUtil.isNotEmpty(resultList)){
                    for (List<SysQuestionRecord> list : resultList) {
                        if(list.get(0).getQuestionId().equals(question.getQuestionId())){
                            question.setRecords(list);
                            break;
                        }
                    }
                }
            }
        }



        List<List<SysQuestion>> questionList= ScoreUtils.groupDataByCondition(questions,new Comparator<SysQuestion>(){
            @Override
            public int compare(SysQuestion o1, SysQuestion o2) {
                return o1.getDomain().equals(o2.getDomain()) ? 0 : -1;
            }
        });

        // 二级指标分数
        List<QuestionDomainScore> secondDomainScores=new ArrayList<>();
        for (SysQuestionDomain sysQuestionDomain:domains){

            if(sysQuestionDomain.getParentId().longValue()!=0){
                for (List<SysQuestion> sysQuestions:questionList){
                    if(sysQuestionDomain.getDomainId().equals(sysQuestions.get(0).getDomain())){
                        secondDomainScores.add(ScoreUtils.getSecondScore(sysQuestionDomain,sysQuestions));
                        break;
                    }
                }
            }
        }



        List<List<QuestionDomainScore>> questionDomainScoreList= ScoreUtils.groupDataByCondition(secondDomainScores,new Comparator<QuestionDomainScore>(){
            @Override
            public int compare(QuestionDomainScore o1, QuestionDomainScore o2) {
                return o1.getParentId().equals(o2.getParentId()) ? 0 : -1;
            }
        });
        // 一级指标分数
        List<QuestionDomainScore> firstDomainScores=new ArrayList<>();
        for (SysQuestionDomain sysQuestionDomain:domains){

            if(sysQuestionDomain.getParentId().longValue()==0){
                for (List<QuestionDomainScore> questionDomainScores1:questionDomainScoreList){
                    if(sysQuestionDomain.getDomainId().equals(questionDomainScores1.get(0).getParentId())){
                        firstDomainScores.add(ScoreUtils.getFirstScore(sysQuestionDomain,questionDomainScores1));
                        break;
                    }
                }
            }
        }

        return AjaxResult.success(firstDomainScores);
    }


    /**
     * 查询企业测评表二级指标分数
     */
    @ApiOperation(value = "查询企业测评表二级指标分数")
    // @PreAuthorize("@ss.hasPermi('system:company:list')")
    @GetMapping("/diagnose/second/score")
    public AjaxResult selectCompanyDiagnoseSecondScore(SysQuestionReqVo questionReqVo){
        SysQuestionDomain domain=new SysQuestionDomain();
        domain.setParentId(questionReqVo.getDomainId());
        List<SysQuestionDomain> domains = domainService.selectQuestionDomainList(domain);

        SysNaire naire = sysNaireService.selectSysNaireByNaireId(questionReqVo.getNaireId());

        Set<Long> quesetionIdList = Arrays.stream(naire.getQuestions().substring(1, naire.getQuestions().length() - 1).split(","))
                .map(s -> Long.parseLong(s.trim()))
                .collect(Collectors.toSet());

        List<SysQuestion> questions = sysQuestionService.selectSysQuestionByQuestionIds(quesetionIdList);

        SysQuestionRecord query=new SysQuestionRecord();
        query.setCompanyId(questionReqVo.getCompanyId());
        query.setNaireId(questionReqVo.getNaireId());
        query.setQuestionId(questionReqVo.getQuestionId());
        List<SysQuestionRecord>  questionRecords=sysQuestionRecordService.selectSysQuestionRecordList(query);

        List<List<SysQuestionRecord>> resultList = ScoreUtils.groupDataByCondition(questionRecords,new Comparator<SysQuestionRecord>(){
            @Override
            public int compare(SysQuestionRecord o1, SysQuestionRecord o2) {
                return o1.getQuestionId().equals(o2.getQuestionId()) ? 0 : -1;
            }
        });

        if(CollUtil.isNotEmpty(questions)){
            for (SysQuestion question:questions){
                if(CollUtil.isNotEmpty(resultList)){
                    for (List<SysQuestionRecord> list : resultList) {
                        if(list.get(0).getQuestionId().equals(question.getQuestionId())){
                            question.setRecords(list);
                            break;
                        }
                    }
                }
            }
        }



        List<List<SysQuestion>> questionList= ScoreUtils.groupDataByCondition(questions,new Comparator<SysQuestion>(){
            @Override
            public int compare(SysQuestion o1, SysQuestion o2) {
                return o1.getDomain().equals(o2.getDomain()) ? 0 : -1;
            }
        });

        // 二级指标分数
        List<QuestionDomainScore> secondDomainScores=new ArrayList<>();
        for (SysQuestionDomain sysQuestionDomain:domains){

            if(sysQuestionDomain.getParentId().longValue()!=0){
                for (List<SysQuestion> sysQuestions:questionList){
                    if(sysQuestionDomain.getDomainId().equals(sysQuestions.get(0).getDomain())){
                        secondDomainScores.add(ScoreUtils.getSecondScore(sysQuestionDomain,sysQuestions));
                        break;
                    }
                }
            }
        }



        List<List<QuestionDomainScore>> questionDomainScoreList= ScoreUtils.groupDataByCondition(secondDomainScores,new Comparator<QuestionDomainScore>(){
            @Override
            public int compare(QuestionDomainScore o1, QuestionDomainScore o2) {
                return o1.getParentId().equals(o2.getParentId()) ? 0 : -1;
            }
        });


        return AjaxResult.success(questionDomainScoreList);
    }



    @ApiOperation(value = "导出企业诊断诊断报告——数字化应用")
    @GetMapping("/digital/report/word/{deptId}")
    public void exportDigitalReportWord(@PathVariable("deptId") Long deptId,HttpServletResponse response) throws IOException {

        Configure config = Configure.builder()
                // isStrict = false , 关闭严格模式, 严格模式下key不存在会报错
                // 关闭后key不存在会被忽略
                // .useSpringEL(true)
                // 表格绑定policy
                .build();

        ClassPathResource classPathResource = new ClassPathResource(DIGITAL_REPORT_WORD_TEMPLATE_PATH);
        SysCompanyInfo sysCompanyInfo=sysCompanyInfoService.selectSysCompanyInfoByCompanyId(deptId);

        if(sysCompanyInfo!=null){
            Map<String, Object> map=new HashMap<String, Object>() {{
                put("companyName", sysCompanyInfo.getCompanyName()!=null?sysCompanyInfo.getCompanyName():"");
                put("registerFund", sysCompanyInfo.getRegisterFund()!=null?sysCompanyInfo.getRegisterFund():"");
                put("companyAddress", sysCompanyInfo.getCompanyAddress()!=null?sysCompanyInfo.getCompanyAddress():"");
                put("companyIdentifier", sysCompanyInfo.getCompanyIdentifier()!=null?sysCompanyInfo.getCompanyIdentifier():"");
                put("lawPerson", sysCompanyInfo.getLawPerson()!=null?sysCompanyInfo.getLawPerson():"");
                put("lawPhone", sysCompanyInfo.getLawPhone()!=null?sysCompanyInfo.getLawPhone():"");
                put("companyProperty", sysCompanyInfo.getCompanyProperty()!=null?sysCompanyInfo.getCompanyProperty():"");
                put("companyIndustry", sysCompanyInfo.getCompanyIndustry()!=null?sysCompanyInfo.getCompanyIndustry():"");
                put("majorProduct", sysCompanyInfo.getMajorProduct()!=null?sysCompanyInfo.getMajorProduct():"");
                put("contactName", sysCompanyInfo.getContactName()!=null?sysCompanyInfo.getContactName():"");
                put("contactPhone", sysCompanyInfo.getContactPhone()!=null?sysCompanyInfo.getContactPhone():"");
                put("totalAssets", sysCompanyInfo.getTotalAssets()!=null?sysCompanyInfo.getTotalAssets():"");
                put("staffNum", sysCompanyInfo.getStaffNum()!=null?sysCompanyInfo.getStaffNum():"");
                put("ipNum", sysCompanyInfo.getIpNum()!=null?sysCompanyInfo.getIpNum():"");
                put("patentNum", sysCompanyInfo.getPatentNum()!=null?sysCompanyInfo.getPatentNum():"");
                put("scNum", sysCompanyInfo.getScNum()!=null?sysCompanyInfo.getScNum():"");
                put("brandNum", sysCompanyInfo.getBrandNum()!=null?sysCompanyInfo.getBrandNum():"");
                put("floorArea", sysCompanyInfo.getFloorArea()!=null?sysCompanyInfo.getFloorArea():"");
                put("plantArea", sysCompanyInfo.getPlantArea()!=null?sysCompanyInfo.getPlantArea():"");
                put("honor", sysCompanyInfo.getHonor()!=null?sysCompanyInfo.getHonor():"");
                put("companyIntro", sysCompanyInfo.getCompanyIntro()!=null?sysCompanyInfo.getCompanyIntro():"");
                put("technicalProcess", sysCompanyInfo.getTechnicalProcess()!=null?sysCompanyInfo.getTechnicalProcess():"");
                put("digitalLevel", sysCompanyInfo.getDigitalLevel()!=null?sysCompanyInfo.getDigitalLevel():"");
                put("question", sysCompanyInfo.getQuestion()!=null?sysCompanyInfo.getQuestion():"");

            }};
            // 字体Wingdings 2的符号

            XWPFTemplate template = XWPFTemplate.compile(classPathResource.getInputStream(),config).render(map);
            OutputStream os = response.getOutputStream();
            // 响应到客户端
            ExcelResponse.disposition(response, "南京市智能化改造数字化转型诊断报告——数字化应用" + ".docx", "attachment", 0);
            template.write(os);
            os.flush();
            os.close();
            if (template != null) {
                template.close();
            }
        }



    }

}
